# encoding=utf-8
# 修改 hibernate 反向过程实体类的代码
# 还应加上package、import 语句
import re, os


def r(p):
    f = open(p)
    c = f.read()
    f.close()
    return c


def lite(s):
    a = re.findall(r'public class [\w]+ ', s)[0]
    a += '\n'.join(['{'] + re.findall('private [^;]+?;', s) + ['}'])
    a = a.replace('private ', 'public ')
    return a


p = r'E:\gs\entity'

for i in os.listdir(p):
    print i
    i = os.path.join(p, i)
    s1 = lite(r(i))
    f = open(i, 'w')
    f.write(s1)
    f.close()
